<!DOCTYPE html>
<html lang="en">
<head>
    <include file="Common/top"/>
    <include file="Common/import_plugin"/>
    <style>
        .layui-table tr td {
            font-size: 12px;
        }
    </style>
</head>
<body>
<include file="Common/nav_menu"/>
<form action="" method="get" class="layui-form">
    <div class="layui-row">
        <div class="layui-col-xs3">
            <input name="order_code" placeholder="单号" class="layui-input" value="{:I('get.order_code')}"/>
        </div>
        <div class="layui-col-xs3">
            <select name="link_seller">
                <option value="0">景区</option>
                <volist name="seller_list" id="vo">
                    <option value="{$vo.id}"
                    <if condition="I('get.link_seller') eq $vo['id']">selected</if>
                    >{$vo.name}</option>
                </volist>
            </select>
        </div>
        <div class="layui-col-xs3">
            <select name="act">
                <option value="0"
                <if condition="I('get.act') eq 0">selected</if>
                >订单状态</option>
                <option value="1"
                <if condition="I('get.act') eq 1">selected</if>
                >成功</option>
                <option value="2"
                <if condition="I('get.act') eq 2">selected</if>
                >已支付</option>
                <option value="3"
                <if condition="I('get.act') eq 3">selected</if>
                >待支付</option>
                <option value="4"
                <if condition="I('get.act') eq 4">selected</if>
                >退票</option>
            </select>
        </div>
        <div class="layui-col-xs3">
            <input type="submit" class="layui-btn layui-btn-normal" value="筛选">
        </div>
    </div>
</form>
<table class="layui-table">
    <tr>
        <!--<td>统一订单号</td>-->
        <td width="100">景区</td>
        <td width="120">单号</td>
        <!--<td width="120">远程订单号</td>-->
        <td width="112">添加时间</td>
        <td width="112">支付时间</td>
        <td width="48">姓名</td>
        <td width="60">电话</td>
        <td class="text-center" width="24">票数</td>
        <td class="text-center" width="24">验证</td>
        <td class="text-center" width="24">退数</td>
        <td style="text-align: right" width="40">总额</td>
        <td class="text-center" width="24">支付</td>
        <td class="text-center" width="24">接口</td>
        <td class="text-center" width="24">退票</td>
        <td class="text-center" width="24">状态</td>
        <td class="text-center">操作</td>
    </tr>
    <volist name="list" id="vo">
        <tr>
            <td>
                <div style="height: 20px;overflow: hidden">
                    {$vo.s_name}
                </div>
            </td>
            <td>{$vo.order_code}</td>
            <!--<td>{$vo.union_order_num}</td>-->
            <td>{:date('Y-m-d H:i:s',$vo['addtime'])}</td>
            <td>
                <if condition="$vo['paytime']">
                    {:date('Y-m-d H:i:s',$vo['paytime'])}
                    <else/>
                    未支付
                </if>
            </td>
            <td>{$vo.real_name}</td>
            <td>{$vo.mobile}</td>
            <td class="text-center" style="color: blue;">{$vo.num}</td>
            <td class="text-center">
                <if condition="$vo['check_num']">
                    <div style="color: red;">{$vo.check_num}</div>
                    <else/>
                    <i style="color: green" class="layui-icon center">&#x1007;</i>
                </if>
            </td>
            <td class="text-center">
                <if condition="$vo['return_num']">
                    <div style="color: red">{$vo.return_num}</div>
                    <else/>
                    <i style="color: green" class="layui-icon center">&#x1007;</i>
                </if>
            </td>
            <td style="text-align: right;color: red;font-weight: bold">{$vo.total_price}</td>
            <td class="text-center">{:getStatus($vo['is_pay'])}</td>
            <td class="text-center">{:getStatus($vo['is_api'])}</td>
            <td class="text-center">{:getStatus($vo['is_return'])}</td>
            <td class="text-center">
                <switch name="vo['status']">
                    <case value="0">
                        <i style="color: red" class="layui-icon center">&#x1007;</i>
                    </case>
                    <case value="1">
                        <i style="color: green" class="layui-icon center">&#x1005;</i>
                    </case>
                    <case value="2">
                        <i style="color: blue" class="layui-icon center">&#xe63f;</i>
                    </case>
                    <default/>
                    <i style="color: red" class="layui-icon center">&#x1007;</i>
                </switch>
            </td>
            <td>
                <a href="{:U('detial',array('id'=>$vo['id']))}" class="layui-btn layui-btn-xs">详细</a>
                <button data-pay="{$vo.is_pay}"
                        data-sign="{$vo.sign}"
                        data-order_code="{$vo.order_code}"
                        data-url="{:U('verity_order' , array('uniton_order_num' => $vo['union_order_num']))}"
                        class="layui-btn layui-btn-normal layui-btn-xs verity_pay">验证支付
                </button>
            </td>
        </tr>
    </volist>
</table>
<div class="page">
    {$page}
</div>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form,
            layer = layui.layer;

        $('.verity_pay').click(function () {
            let self = $(this);
            $.ajax({
                url: $(this).attr('data-url'),
                data: {},
                beforeSend: function () {
                    layer.msg('验证中 ...');
                },
                success: function (req) {
                    let msg = req.paymsg;
                    if (req.paycode === 1 && self.attr('data-pay') === '0') {
                        layer.open({
                            content: '<div style="text-align: center">' + msg + '</div>' + '<br/>数据校准不正确!是否向 Api 发送申请!',
                            btn: ['发送', '取消'],
                            yes: function () {
                                let url = '/index.php/Home/Payment/piaofutong_unionOrderNumCallback/order_code/' + self.attr('data-order_code') + '/sign/' + self.attr('data-sign');
                                $.ajax({
                                    url: url,
                                    data: {},
                                    success: function (req) {
                                        window.location.reload()
                                    },
                                    beforeSend: function () {
                                        layer.msg('正在发送...')
                                    }
                                })
                            }
                        });
                    } else {
                        layer.msg(msg);
                    }
                }
            })
        })
    })
</script>
</body>
</html>